#include <iostream>
#include <string>

// 抽象实例
class AbstractionImp
{
public:
    virtual ~AbstractionImp() {}
    virtual void Operation() = 0;

protected:
    AbstractionImp() {}
};

// 抽象实例实例-方法
class Abstraction
{
public:
    virtual ~Abstraction() {}
    virtual void Operation() = 0;

protected:
    Abstraction() {}
};

// 桥接适配
class RefinedAbstaction : public Abstraction
{
public:
    RefinedAbstaction(AbstractionImp *imp)
    {
        _imp = imp;
    }
    ~RefinedAbstaction() {}
    void Operation()
    {
        _imp->Operation();
    }

private:
    AbstractionImp *_imp;
};

// 具体实例A
class ConcreteAbstractionImpA : public AbstractionImp
{
public:
    ConcreteAbstractionImpA() {}
    ~ConcreteAbstractionImpA() {}
    virtual void Operation()
    {
        std::cout << "ConcreteAbstractionImpA...." << std::endl;
    }
};

// 具体实例B
class ConcreteAbstractionImpB : public AbstractionImp
{
public:
    ConcreteAbstractionImpB() {}
    ~ConcreteAbstractionImpB() {}
    virtual void Operation()
    {
        std::cout << "ConcreteAbstractionImpB...." << std::endl;
    }
};

int main()
{
    AbstractionImp *imp = new ConcreteAbstractionImpA();
    Abstraction *abs = new RefinedAbstaction(imp);
    abs->Operation();

    AbstractionImp *imp_b = new ConcreteAbstractionImpB();
    Abstraction *abs_b = new RefinedAbstaction(imp_b);
    abs_b->Operation();

    return 0;
}